home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / metamail / contrib / sh-versions / showaudio < prev    next >
Encoding:
Text File  |  1993-05-18  |  5.1 KB  |  193 lines

  1. :
  2. # Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
  3. # Permission to use, copy, modify, and distribute this material 
  4. # for any purpose and without fee is hereby granted, provided 
  5. # that the above copyright notice and this permission notice 
  6. # appear in all copies, and that the name of Bellcore not be 
  7. # used in advertising or publicity pertaining to this 
  8. # material without the specific, prior written permission 
  9. # of an authorized representative of Bellcore.  BELLCORE 
  10. # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY 
  11. # OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS", 
  12. # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  13.  
  14. # Conversion from C shell to Bourne shell by Z-Code Software Corp.
  15. # Conversion Copyright (c) 1992 Z-Code Software Corp.
  16. # Permission to use, copy, modify, and distribute this material
  17. # for any purpose and without fee is hereby granted, provided
  18. # that the above copyright notice and this permission notice
  19. # appear in all copies, and that the name of Z-Code Software not
  20. # be used in advertising or publicity pertaining to this
  21. # material without the specific, prior written permission
  22. # of an authorized representative of Z-Code.  Z-CODE SOFTWARE
  23. # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
  24. # OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS",
  25. # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  26.  
  27. thishost=`hostname`
  28.  
  29. AUDIOBINDIR=/u/andrew/phone-sau/bin
  30. AUDIOPHONEHOST=greenbush
  31. AUDIOPHONEHOSTLONG=greenbush.bellcore.com
  32. ORG=Bellcore
  33.  
  34. if test "$1" = "-p"
  35. then
  36.     AUDIOPHONE=$2
  37.     shift
  38.     shift
  39. fi
  40.  
  41. if test "$1" = "-s"
  42. then
  43.     AUDIOSPEAKERFORCE=1
  44. fi
  45.  
  46. playphone=0
  47. if test ! -z "${AUDIOPHONE:-}" -o ! -z "${AUDIOPHONEFORCE:-}"
  48. then
  49.     playphone=1
  50. fi
  51.  
  52. if test $playphone -eq 0
  53. then
  54.     if test ! -d "$AUDIOBINDIR"
  55.     then
  56.         AUDIOSPEAKERFORCE=1
  57.     fi
  58.  
  59.     if test -z "${AUDIOSPEAKERFORCE:-}" -a -z "${AUDIOPHONEFORCE:-}"
  60.     then
  61.         if test ! -z "${MM_NOTTTY:-}"
  62.         then
  63.             if test $MM_NOTTTY -eq 1
  64.             then
  65.                 MM_NOTTTY=0; export MM_NOTTTY
  66.                 xterm -e showaudio $*
  67.                 exit 0
  68.             fi
  69.         fi
  70.         echo This program can display audio on the speakers of some workstations, 
  71.         echo "or (at some sites) it can call you on the telephone.  Please choose one:"
  72.         echo ""
  73.         echo "1 -- Use the computer's speaker"
  74.         echo "2 -- Call me on the telephone"
  75.         echo ""
  76.         echo-n "Which do you prefer (1 or 2)? [1] "
  77.         read ans
  78.         if test "$ans" -eq 2
  79.         then
  80.             echo "OK, we'll use the telephone..."
  81.             AUDIOPHONEFORCE=1
  82.             echo "In the future, you can avoid this question by setting the environment variable"
  83.             echo "AUDIOPHONEFORCE to 1"
  84.             playphone=1
  85.         else
  86.             echo "OK, Attempting to play the audio using your computer's speaker.."
  87.             AUDIOSPEAKERFORCE=1
  88.             echo "In the future, you can avoid this question by setting the environment variable"
  89.             echo "AUDIOSPEAKERFORCE to 1"
  90.         fi
  91.     fi
  92. fi
  93.  
  94. if test $playphone -eq 0
  95. then
  96.     audiohost=$thishost
  97.     if test ! -z "${DISPLAY:-}"
  98.     then
  99.         audiohost=`echo $DISPLAY | sed -e 's/:.*//'`
  100.         if test "$audiohost" = unix
  101.         then
  102.             audiohost=$thishost
  103.         fi
  104.         if test -z "$audiohost"
  105.         then
  106.             audiohost=$thishost
  107.         fi
  108.     fi
  109.     if test ! -z "${AUDIOHOST:-}"
  110.     then
  111.         audiohost=$AUDIOHOST
  112.     fi
  113.  
  114.     if test ! "$audiohost" = "$thishost"
  115.     then
  116.         echo Sending audio to $audiohost...
  117.         thisprog=`(cd; which showaudio)`
  118.         cat $* | rsh $audiohost $thisprog -s
  119.         exit 0
  120.     fi
  121.  
  122.     if test -d /usr/sony
  123.     then
  124.         dev=/dev/sb0
  125.     else
  126.         dev=/dev/audio
  127.     fi
  128.  
  129.     if test -f /usr/sbin/sfplay
  130.     then
  131.         file $* | grep AIFF > /dev/null 2>&1
  132.         if test $? -eq 0
  133.         then
  134.             echo Playing AIFF audio on $thishost using /usr/sbin/sfplay, one moment...
  135.             /usr/sbin/sfplay $*
  136.         else
  137.             echo Playing NeXT/Sun-format audio on $thishost using /usr/sbin/sfplay...
  138.             /usr/sbin/sfplay -i format next end $*
  139.         fi
  140.         exit 0
  141.     fi
  142.  
  143.     if test -w $dev
  144.     then
  145.         echo Playing audio on $thishost using $dev, one moment please...
  146.         cat $* > $dev
  147.         exit 0
  148.     fi
  149. fi
  150.  
  151. if test -d "$AUDIOBINDIR"
  152. then
  153.     thisprog=`which showaudio`
  154.     if test -z "${AUDIOPHONE:-}"
  155.     then
  156.         if test ! -z "${MM_NOTTTY:-}"
  157.         then
  158.             if test $MM_NOTTTY -eq 1
  159.             then
  160.                 MM_NOTTTY=0; export MM_NOTTTY
  161.                 xterm -e $thisprog $*
  162.                 exit 0
  163.             fi
  164.         fi
  165.         echo This message contains audio, which can be sent to your telephone.
  166.         echo Please enter the telephone number at which you would like to hear this
  167.         echo-n "audio message as you would dial it from inside ${ORG}: "
  168.         read AUDIOPHONE
  169.     fi
  170.  
  171.     if test "$thishost" == "$AUDIOPHONEHOST" \
  172.         -o "$thishost" == "$AUDIOPHONEHOSTLONG"
  173.     then
  174.         echo Calling Phone number $AUDIOPHONE
  175.         echo "If the process seems stuck after you hang up,"
  176.         echo "then please interrupt with ^C or whatever your interrupt key is"
  177.         cat $AUDIOBINDIR/../GREET.au $* - | $AUDIOBINDIR/play -\# $AUDIOPHONE -
  178.         echo All done
  179.         exit 0
  180.     else
  181.         echo Trying to rsh to $AUDIOPHONEHOST to send audio via telephone
  182.         cat $* | rsh $AUDIOPHONEHOST $thisprog -p $AUDIOPHONE
  183.         exit 0
  184.     fi
  185. fi
  186. echo ""
  187. echo "This message contains an audio mesage, which can not currently be"
  188. echo "played on this type of workstation.   If you log into an appropriate"
  189. echo "machine (currently a SPARCstation or Sony News workstation)"
  190. echo "and read this message there, you should be able to hear the audio"
  191. echo "message."
  192.